<template>
  <el-card :bordered="false" class="addOrder avue_height">
    <el-page-header
      @back="$router.go(-1)"
      style="margin-bottom: 10px"
    ></el-page-header>
    <el-form
      :model="ruleForm"
      ref="ruleForm"
      :labelWidth="labelWidth"
      class="demo-ruleForm"
    >
      <el-row :gutter="10">
        <el-col :xs="24">
          <el-form-item label="区域图片：" ref="lmtbUpload">
            <el-upload
              :headers="headers"
              action="/admin/sys-file/upload"
              list-type="picture-card"
              :auto-upload="true"
              :before-upload="beforeUpload"
              :on-success="handleGoodsPicUploadSuccess"
              :on-progress="onProgress"
              :file-list="fileList"
              :limit="1"
              :class="{ disUoloadSty: fileList.length }"
            >
              <i slot="default" class="el-icon-plus"></i>
              <div slot="tip" class="el-upload__tip">
                建议上传大小不超过1M，尺寸为 326*412 的图片
              </div>
              <div slot="file" slot-scope="{ file }">
                <div
                  class="el-loading-mask"
                  style="background-color: rgba(0, 0, 0, 0.8)"
                  v-if="file.status === 'uploading'"
                >
                  <div class="el-loading-spinner">
                    <i class="el-icon-loading" style="font-size: 20px"></i>
                    <p class="el-loading-text">正在上传中...</p>
                  </div>
                </div>
                <img
                  class="el-upload-list__item-thumbnail"
                  :src="file.url"
                  alt
                  v-if="uploading"
                />
                <span class="el-upload-list__item-actions">
                  <span
                    class="el-upload-list__item-preview"
                    @click="handlePictureCardPreview(file)"
                  >
                    <i class="el-icon-zoom-in"></i>
                  </span>
                  <span
                    class="el-upload-list__item-delete"
                    @click="delUplod(file)"
                  >
                    <i class="el-icon-delete"></i>
                  </span>
                </span>
              </div>
            </el-upload>
            <el-dialog :visible.sync="dialogVisibleImg" title="查看大图">
              <img width="100%" :src="dialogImageUrl" alt />
            </el-dialog>
            <!-- modal -->
            <!-- <cropper-modal
              ref="cropperModal"
              :optionsData="optionsData"
              @ok="handleCropperSuccess"
            ></cropper-modal> -->
          </el-form-item>
        </el-col>
        <p>（说明：优惠券自动取可显示待生效、已生效的优惠券）</p>
      </el-row>
      <div class="content">
        <el-button
          type="primary"
          @click="submitSave('ruleForm')"
          :loading="loadingSure"
          >{{ ruleForm.id ? "修改" : "提交" }}</el-button
        >
        <el-button @click="quxiao('ruleForm')">取消</el-button>
      </div>
    </el-form>
  </el-card>
</template>

<script src='./index.js'></script>

<style lang="scss">
.addOrder {
  .content {
    text-align: center;
    margin: 20px 0px;
    button {
      margin-right: 10px;
    }
  }
}
.uoloadSty .el-upload--picture-card {
  width: 148px;
  height: 148px;
  line-height: 146px;
}
.disUoloadSty .el-upload--picture-card {
  display: none; /* 上传按钮隐藏 */
}
.el-upload-list__item > div {
  width: 100%;
  height: 100%;
}
</style>
